﻿<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="renderer" content="ie-stand">
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->

<title>首页</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/static/xcConfirm/css/xcConfirm.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-1.11.1.min.js" ></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/xcConfirm/js/xcConfirm.js" ></script>
</head>
<body style="background-color:#f9f9f9">
<style type="text/css">
	.li-bord{
		background: #d0e1f7;
		flex-grow:0;
		flex-basis:200px;
		text-align:center;
		padding:15px;
		border:1px #222 solid;
		margin:10px;
	
	}
	.li-bord a{
		cursor:pointer;
		font-size: 1.5em;
	    font-weight: bold;
		padding:20px 0;
		display : block;
	}
	
	
	.li-bord:hover{
		background: #b0d6fb;
		flex-grow:0;
		flex-basis:200px;
		text-align:center;
		padding:15px;
		border:1px #222 solid;
		margin:10px;
	}
</style>
<div>
	<div style="width:100%;max-width:1300px;margin:40px auto;padding:0 20px;box-sizing:border-box;">
		<ul style="display:flex;flex-wrap:wrap;list-style-type:none;padding: 0;">
			<li class="li-bord" title="用户名：admin 密码：admin">
				<a a-name="启动8_5_2密检中心" a-href="http://192.168.3.19:8090/sctr">绵阳密检系统</a>
				<img load-flag="false" src="${pageContext.request.contextPath}/static/images/false.png">
			</li>
			<li class="li-bord" title="用户名：admin 密码：admin">
				<a a-name="启动8_5_3后勤管理系统" a-href="http://192.168.3.19:8091/hqgl">西藏武警后勤管理</a>
				<img load-flag="false" src="${pageContext.request.contextPath}/static/images/false.png">
			</li>
			<li class="li-bord" title="用户名：admin 密码：admin">
				<a a-name="启动8_5_4警务管理系统" a-href="http://192.168.3.19:8092/jwgl">西藏武警警务管理</a>
				<img load-flag="false" src="${pageContext.request.contextPath}/static/images/false.png">
			</li>
			<li class="li-bord" title="用户名：admin 密码：admin">
				<a a-name="启动8_5_5BUG管理系统" a-href="http://192.168.3.19:8093/bugsys">bug管理</a>
				<img load-flag="false" src="${pageContext.request.contextPath}/static/images/false.png">
			</li>
			<li class="li-bord" title="用户名：admin 密码：admin">
				<a a-name="启动8_5_6政治管理系统" a-href="http://192.168.3.19:8094/zzgl">西藏武警政治管理</a>
				<img load-flag="false" src="${pageContext.request.contextPath}/static/images/false.png">
			</li>
			<li class="li-bord" title="用户名：admin 密码：admin">
				<a a-name="启动8_5_7公司知识库系统" a-href="http://192.168.3.19:8095/hxsr">中科合迅知识库</a>
				<img load-flag="false" src="${pageContext.request.contextPath}/static/images/false.png">
			</li>
			<li class="li-bord" title="用户名：admin 密码：123456">
				<a a-name="启动8_5_8外购管理系统" a-href="http://192.168.3.19:8096">外购管理系统</a>
				<img load-flag="false" src="${pageContext.request.contextPath}/static/images/false.png">
			</li>
			<li class="li-bord" title="用户名：admin 密码：root123456">
				<a a-name="启动8_5_9水工知识库系统" a-href="http://192.168.3.19:8097/exp">水工知识库系统</a>
				<img load-flag="false" src="${pageContext.request.contextPath}/static/images/false.png">
			</li>
			<li class="li-bord" title="用户名：root 密码：root123456">
				<a a-name="启动7.0_82备用备件" a-href="http://192.168.3.19:8098/spare">备品备件</a>
				<img load-flag="false" src="${pageContext.request.contextPath}/static/images/false.png">
			</li>
			<li class="li-bord" title="用户名：admin 密码：admin">
				<a a-name="启动8_5_10核设备检测旧" a-href="http://192.168.3.19:8099/npc/loginOld.jsp">核设备检测(一期)</a>
				<img load-flag="false" src="${pageContext.request.contextPath}/static/images/false.png">
			</li>
			<li class="li-bord" title="用户名：admin 密码：admin">
				<a a-name="启动8_5_10核设备检测旧" a-href="http://192.168.3.19:8099/npc/loginOld.jsp">核设备检测(二期)</a>
				<img load-flag="false" src="${pageContext.request.contextPath}/static/images/false.png">
			</li>
			<li class="li-bord" title="用户名：admin 密码：admin">
				<a a-name="启动8_5_10核设备检测旧" a-href="http://192.168.3.19:8099/npc/login.jsp">核设备检测(三期)</a>
				<img load-flag="false" src="${pageContext.request.contextPath}/static/images/false.png">
			</li>
			<li class="li-bord" title="用户名：admin 密码：admin">
				<a a-name="启动8_5_11核设备检测新" a-href="http://192.168.3.19:8100/tube/">核设备检测(四期)</a>
				<img load-flag="false" src="${pageContext.request.contextPath}/static/images/false.png">
			</li>
			
			<li class="li-bord" title="用户名：admin 密码：admin">
				<a a-name="启动8_5_12三十八所mes" a-href="http://192.168.3.19:8101/mes">38所mes</a>
				<img load-flag="false" src="${pageContext.request.contextPath}/static/images/false.png">
			</li>
			
		</ul>
	</div>
</div>
<script type="text/javascript">
(function(){
	$(function(){
		
		$.ajax({
			type:"post",
			url:"${pageContext.request.contextPath}/prmAction.do?mothod=portStatus",
			data:{},
			success:function(res){
				console.log(res)
			}
		})
		loadWebsocket();
	})
	
	$(".li-bord").find("a").each(function(){
		$(this).on("click",function(){
			loadData(this)
		})
	})
	//加载数据
	function loadData(_this){
		var _that=$(_this);
		var name=_that.attr("a-name")||"";
		var url=_that.attr("a-href")||"";
		if(url=="") return;
		window.wxc.msg("项目启动中,请稍候...",{time:3000});
		
		//点击后禁用,直到启动完成
		$(_that).css("pointer-events","none"); 
		$.ajax({
			type:"post",
			data:{project_name:name},
			url:"${pageContext.request.contextPath}/prmAction.do?mothod=runBat",
			success:function(res){
				console.log(res);
				if(res=="ok"){
					//window.wxc.xcConfirm("端口启用完成!请等待项目启动...","info");
				}
				//window.open(url);
			}
		})
	}
	
	//接收websocket消息
	function loadWebsocket(){
		var path = window.location.host+"${pageContext.request.contextPath }/";
		var userId = 'dream';
		if(userId==-1){
			window.location.href="${pageContext.request.contextPath }/studentAction/testmvc";
		}
		var jspCode = userId+"_"+(new Date()).getTime();
		var websocket;
		if ('WebSocket' in window) {
			websocket = new WebSocket("ws://" + path + "wsMy?jspCode=" + jspCode);
		} else if ('MozWebSocket' in window) {
			websocket = new MozWebSocket("ws://" + path + "wsMy?jspCode=" + jspCode);
		} else {
			websocket = new SockJS("http://" + path + "wsMy/sockjs?jspCode=" + jspCode);
		}
		websocket.onopen = function(event) {
			console.log("WebSocket:已连接");
			//console.log(event);
		};
		websocket.onmessage = function(event) {
			var data = JSON.parse(event.data);
			console.log("WebSocket:收到一条消息-norm", data);
			receiptMsg(data);
		};
		websocket.onerror = function(event) {
			console.log("WebSocket:发生错误 ");
			console.log(event);
		};
		websocket.onclose = function(event) {
			console.log("WebSocket:已关闭");
			console.log(event);
		}
	}
	//接收消息
	function receiptMsg(data){
		
		$(".li-bord").find("a").each(function(){
			var url=$(this).attr("a-href")||$(this).attr("href")||"";
			var _$img=$(this).next();
			//加载标记,默认false
			var load_flag=_$img.attr("load-flag")||"false";
			load_flag=JSON.parse(load_flag)
			
			for(var i=0;i<data.length;i++){
				//如果链接包含这个端口,并且端口被使用
				if(url.indexOf(data[i].port)>=0){
					//状态与标记不同时才加载数据,只有更新时才加载数据
					if(data[i].status!=load_flag){
						_$img.attr("load-flag",!load_flag);
						if(data[i].status==true){
							_$img.attr("src","${pageContext.request.contextPath}/static/images/success.png");
							$(this).removeAttr("a-href");
							$(this).attr("href",url);
							$(this).css("pointer-events","auto");
						}else{
							_$img.attr("src","${pageContext.request.contextPath}/static/images/false.png");
							$(this).removeAttr("href");
							$(this).attr("a-href",url);
							$(this).css("pointer-events","auto");
						}
					}
					
					break;
				}
			}
		})
	}
})()
</script>
</body>
</html>